<?php
class TesteeanswersController extends AppController {

	var $name = 'Testeeanswers';

	function index() {
		$this->Testeeanswer->recursive = 0;
		$this->set('testeeanswers', $this->paginate());
	}

	function view($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid testeeanswer', true));
			$this->redirect(array('action' => 'index'));
		}
		$this->set('testeeanswer', $this->Testeeanswer->read(null, $id));
	}

	function add() {
		if (!empty($this->data)) {
			$this->Testeeanswer->create();
			if ($this->Testeeanswer->save($this->data)) {
				$this->Session->setFlash(__('The testeeanswer has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The testeeanswer could not be saved. Please, try again.', true));
			}
		}
		$questions = $this->Testeeanswer->Question->find('list');
		$choices = $this->Testeeanswer->Choice->find('list');
		$testees = $this->Testeeanswer->Testee->find('list');
		$this->set(compact('questions', 'choices', 'testees'));
	}

	function edit($id = null) {
		if (!$id && empty($this->data)) {
			$this->Session->setFlash(__('Invalid testeeanswer', true));
			$this->redirect(array('action' => 'index'));
		}
		if (!empty($this->data)) {
			if ($this->Testeeanswer->save($this->data)) {
				$this->Session->setFlash(__('The testeeanswer has been saved', true));
				$this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The testeeanswer could not be saved. Please, try again.', true));
			}
		}
		if (empty($this->data)) {
			$this->data = $this->Testeeanswer->read(null, $id);
		}
		$questions = $this->Testeeanswer->Question->find('list');
		$choices = $this->Testeeanswer->Choice->find('list');
		$testees = $this->Testeeanswer->Testee->find('list');
		$this->set(compact('questions', 'choices', 'testees'));
	}

	function delete($id = null) {
		if (!$id) {
			$this->Session->setFlash(__('Invalid id for testeeanswer', true));
			$this->redirect(array('action'=>'index'));
		}
		if ($this->Testeeanswer->delete($id)) {
			$this->Session->setFlash(__('Testeeanswer deleted', true));
			$this->redirect(array('action'=>'index'));
		}
		$this->Session->setFlash(__('Testeeanswer was not deleted', true));
		$this->redirect(array('action' => 'index'));
	}
}
